<%@ page language="java"  contentType="text/html;charset=utf-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Insert title here</title>
</head>
<body>
<style type="text/css">
  body{background-image:url(tp/jj.jpg);
       background-size:cover;
  }
  </style>
<center>
<form action="index.jsp" method="post">
<h2>您选的课程为：</h2>
<%out.println("<br/>"); %>
<%out.println("<br/>"); %>
<% 
   request.setCharacterEncoding("utf-8");
   String yh=request.getParameter("name");
     out.print("学号:" + yh);
   request.setCharacterEncoding("utf-8");
   Connection con;
   Statement sql; 
   ResultSet rs;
   try{  Class.forName("com.mysql.jdbc.Driver");
     
   }
   catch(Exception e){} 
   String url = "jdbc:mysql://127.0.0.1/warehouse?useUnicode=true&characterEncoding=utf-8";
   String user="root";
   String password="";
   con=DriverManager.getConnection(url,user,password);
   sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);    
   rs=sql.executeQuery("SELECT * FROM "+"course where yhm="+"'"+yh.trim()+"'");  
  
     ResultSetMetaData metaData = rs.getMetaData();
     int columnCount = metaData.getColumnCount(); 
     rs.beforeFirst();
     out.print("<br>");
     out.print("<table border=5>");
     //out.print("<caption>您的所选课程</caption>");
     out.print("<tr>");
     out.print("<th width=100>"+"选修课1");
     out.print("<th width=100>"+"选修课2");
     out.print("<th width=100>"+"选修课3");
     out.print("<th width=100>"+"用户名");
     int i=0;
     while(rs.next()){
     	out.print("<tr>");
     	for(int k=0;k<columnCount;k++)
     	{
     		
     		out.print("<td>"+rs.getString(k+1)+"</td>");
     	}
     	out.print("</tr>");
     	i++;
     }
     out.print("</table>");
     con.close();

   %>
   <br>
   <tr><td><input type="submit" value="退出"/></td>
</center>
</body>
</html>